package com.runa.monitor.platinterface.config;

import com.runa.monitor.platinterface.base.exception.OperationException;
import com.runa.monitor.comm.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionAdvice {


    @ExceptionHandler(OperationException.class)
    public Result  operaErrorHandler(OperationException e) {
//        Map<String, Object> error = newComm HashMap<>(1);
//        error.put("code", );
//        error.put("msg", e.getMsg());
        log.error("通信调用报错OperationException: ", e);
        return Result.error(String.valueOf(e.getCode()),"通信调用报错 — "+e);
    }

    @ExceptionHandler(Exception.class)
    public Result  generalErrorHandler(Exception e) {
//        Map<String, Object> error = newComm HashMap<>(1);
//        error.put("code", );
//        error.put("msg", );
        log.error("通信调用报错Exception: ", e);
        return Result.error("500","通信调用报错 — "+e);
    }

}
